package com.xiaosu.red_travel.mapper;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xiaosu.red_travel.constant.Code;
import com.xiaosu.red_travel.group.Group;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("tab_user")
public class User {

    @TableId(type = IdType.AUTO)
    @NotNull(message = Code.IDNOTNULL,groups = {Group.Update.class, Group.Id.class})
    private Integer id;

    @NotNull(message = Code.USERNAMENOTNULL,groups = {Group.Register.class,Group.Login.class,Group.Update.class})
    @Size(min = 5,max = 10,groups = {Group.Register.class,Group.Update.class})
    private String username;

    @NotNull(message = Code.PASSWORDNOTNULL,groups = {Group.Register.class,Group.Login.class,Group.Update.class})
    @Size(min = 6,max = 15,groups = {Group.Register.class,Group.Update.class})
    private String password;

    @NotNull(message = Code.NAMENOTNULL,groups = {Group.Register.class,Group.Update.class})
    private String name;

    @NotNull(message = Code.ADDRESSNOTNULL,groups = {Group.Register.class,Group.Update.class})
    private String address;

    @NotNull(message = Code.PHONENOTNULL,groups = {Group.Register.class,Group.Update.class})
    @Size(min = 11,max = 11,groups = {Group.Register.class,Group.Update.class})
    private String phone;

    @TableField("head_pic")
    private String headPic;
    private String identity;

}
